package joyi.train.cheng.domain;

import j.framework.domain.BaseDomain;
import j.util.jdbc.simple.annotation.Column;
import j.util.jdbc.simple.annotation.Table;

/**
 * Created by WY2015092804 on 2015/10/12.
 */
@Table(name = "cheng_City", pkColumns = "cityId", ukColumns = "parentId,cityName", isTree = true,
        parentFieldName = "parentId", leftFieldName = "leftValue", rightFieldName = "rightValue")
public class City extends BaseDomain {
    @Override
    public void setId(String id) {
        this.cityId = id;
    }

    @Override
    public String getId() {
        return cityId;
    }

    private String cityId;

    @Column(nullable = false)
    private String cityName;

    private String parentId;


    private Integer leftValue;

    private Integer rightValue;

    private String note;


    public String getCityId() {
        return cityId;
    }

    public void setCityId(String cityId) {
        this.cityId = cityId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getLeftValue() {
        return leftValue;
    }

    public void setLeftValue(Integer leftValue) {
        this.leftValue = leftValue;
    }

    public Integer getRightValue() {
        return rightValue;
    }

    public void setRightValue(Integer rightValue) {
        this.rightValue = rightValue;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Override
    public String toString() {
        return "City{" +
                "cityId='" + cityId + '\'' +
                ", cityName='" + cityName + '\'' +
                ", parentId='" + parentId + '\'' +
                ", leftValue=" + leftValue +
                ", rightValue=" + rightValue +
                ", note='" + note + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        City city = (City) o;

        if (cityId != null ? !cityId.equals(city.cityId) : city.cityId != null) return false;
        if (cityName != null ? !cityName.equals(city.cityName) : city.cityName != null) return false;
        if (parentId != null ? !parentId.equals(city.parentId) : city.parentId != null) return false;
        if (leftValue != null ? !leftValue.equals(city.leftValue) : city.leftValue != null) return false;
        if (rightValue != null ? !rightValue.equals(city.rightValue) : city.rightValue != null) return false;
        return !(note != null ? !note.equals(city.note) : city.note != null);

    }

    @Override
    public int hashCode() {
        int result = cityId != null ? cityId.hashCode() : 0;
        result = 31 * result + (cityName != null ? cityName.hashCode() : 0);
        result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
        result = 31 * result + (leftValue != null ? leftValue.hashCode() : 0);
        result = 31 * result + (rightValue != null ? rightValue.hashCode() : 0);
        result = 31 * result + (note != null ? note.hashCode() : 0);
        return result;
    }
}
